/**
46 * <pre>
 * Copyright Notice:
 *    Copyright (c) 2005-2009 China Financial Certification Authority(CFCA)
 *    A-1 You An Men Nei Xin An Nan Li, Xuanwu District, Beijing ,100054, China
 *    All rights reserved.
 * 
 *    This software is the confidential and proprietary information of
 *    China Financial Certification Authority (&quot;Confidential Information&quot;).
 *    You shall not disclose such Confidential Information and shall use
 *    it only in accordance with the terms of the license agreement you
 *    entered into with CFCA.
 * </pre>
 */

package payment.simulator.institution.tx.common;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import payment.api.system.PaymentUserEnvironment;
import payment.api.system.TxMessenger;
import payment.api.tx.TxBaseResponse;
import payment.api.tx.p2p.Tx3116Response;
import payment.api.tx.p2p.Tx3131Response;
import payment.api.tx.p2p.Tx3136Response;
import payment.api.tx.p2p.Tx3137Response;
import payment.api.tx.p2p.Tx3138Response;
import payment.api.tx.p2p.Tx3141Response;
import payment.api.tx.p2p.Tx3146Response;
import payment.api.tx.p2p.Tx3151Response;
import payment.api.tx.p2p.Tx3156Response;
import payment.api.tx.p2p.Tx3161Response;
import payment.api.tx.p2p.Tx3162Response;
import payment.api.tx.p2p.Tx3216Response;
import payment.api.tx.p2p.Tx3231Response;
import payment.api.tx.p2p.Tx3236Response;
import payment.api.tx.p2p.Tx3237Response;
import payment.api.tx.p2p.Tx3238Response;
import payment.api.tx.p2p.Tx3241Response;
import payment.api.tx.p2p.Tx3246Response;
import payment.api.tx.p2p.Tx3251Response;
import payment.api.tx.p2p.Tx3256Response;
import payment.api.tx.p2p.Tx3261Response;
import payment.api.tx.p2p.Tx3262Response;
import payment.api.tx.p2p.Tx3291Response;
import payment.api.tx.p2p.Tx3292Response;
import payment.api.tx.p2p.Tx3310Response;
import payment.api.tx.p2p.Tx3312Response;
import payment.api.tx.p2p.Tx3315Response;
import payment.api.tx.paymentaccount.Tx4202Response;
import payment.api.tx.paymentaccount.Tx4206Response;
import payment.api.tx.paymentaccount.Tx4211Response;
import payment.api.tx.paymentaccount.Tx4212Response;
import payment.api.tx.paymentaccount.Tx4221Response;
import payment.api.tx.paymentaccount.Tx4232Response;
import payment.api.tx.paymentaccount.Tx4236Response;
import payment.api.tx.paymentaccount.Tx4237Response;
import payment.api.tx.paymentaccount.Tx4238Response;
import payment.api.tx.paymentaccount.Tx4239Response;
import payment.api.tx.paymentaccount.Tx4244Response;
import payment.api.tx.paymentaccount.Tx4252Response;
import payment.api.tx.paymentaccount.Tx4256Response;
import payment.api.tx.paymentaccount.Tx4264Response;
import payment.api.tx.paymentaccount.Tx4273Response;
import payment.api.tx.paymentaccount.Tx4276Response;
import payment.api.tx.paymentaccount.Tx4280Response;
import payment.api.tx.paymentaccount.Tx4321Response;
import payment.api.tx.paymentaccount.Tx4328Response;
import payment.api.tx.paymentaccount.Tx4333Response;
import payment.api.tx.paymentaccount.Tx4336Response;
import payment.api.vo.PaymentBankAccount;

/**
 * 发送同步交易请求到支付平台
 * 
 * <pre>
 * Modify Information:
 * Author       Date        Description
 * ============ =========== ============================
 * caohc        2018-12-10  新增
 * 
 * 
 * </pre>
 */
public class SendMessage4P2P extends HttpServlet {

    private static final long serialVersionUID = -9113676340998312853L;

    private static final Logger logger = Logger.getLogger("system");

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            // 获得参数message和signature
            String message = request.getParameter("message");
            String signature = request.getParameter("signature");
            String txCode = request.getParameter("txCode");
            String txName = request.getParameter("txName");
            // 与支付平台进行通讯
            TxMessenger txMessenger = new TxMessenger();
            String[] respMsg = null;
            
            // HTTP默认连接超时时间是25s，读超时时间是25s
            // HTTPS默认连接超时时间是50s，读超时时间是50s
            respMsg = txMessenger.send(message, signature, PaymentUserEnvironment.paymentusertxURL);// 0:message;
            // 设置连接超时时间和读超时时间
            // int connectTimeoutLimit = 50000; 设置连接超时时间（单位ms）
            // int readTimeoutLimit = 50000; 设置读超时时间（单位ms）
            // respMsg = txMessenger.send(message, signature,
            // connectTimeoutLimit, readTimeoutLimit,
            // AggregateEnvironment.aggregateTxURL);
            // 0:message;
            // 1:signature
            String plainText = new String(cpcn.institution.tools.util.Base64.decode(respMsg[0]), "UTF-8");

            logger.debug("[message]=[" + respMsg[0] + "]");
            logger.debug("[signature]=[" + respMsg[1] + "]");
            logger.debug("[plainText]=[" + plainText + "]");

            // 将结果保存在request中，以备在Response.jsp页面显示
            // //商户交易
            if ("3116".equals(txCode)) {// P2P支付查询
                Tx3116Response tx3116Response = new Tx3116Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3116Response.getResponsePlainText());
                if ("2000".equals(tx3116Response.getCode())) {
                    logger.info("[Message]=[" + tx3116Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3141".equals(txCode)) {// P2P还款
                Tx3141Response tx3141Response = new Tx3141Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3141Response.getResponsePlainText());
                if ("2000".equals(tx3141Response.getCode())) {
                    logger.info("[Message]=[" + tx3141Response.getMessage() + "]");
                    if (tx3141Response.getStatus() == 30 || tx3141Response.getStatus() == 40) {
                        logger.info("[RepaymentTime]=[" + tx3141Response.getRepaymentTime() + "]");
                    }
                    // 处理业务
                }
            } else if ("3131".equals(txCode)) {// P2P项目结算
                Tx3131Response tx3131Response = new Tx3131Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3131Response.getResponsePlainText());
                if ("2000".equals(tx3131Response.getCode())) {
                    logger.info("[Message]=[" + tx3131Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3136".equals(txCode)) {// P2P项目结算查询
                Tx3136Response tx3136Response = new Tx3136Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3136Response.getResponsePlainText());
                if ("2000".equals(tx3136Response.getCode())) {
                    logger.info("[Message]=[" + tx3136Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3137".equals(txCode)) {// P2P项目账户转账结算
                Tx3137Response txResponse = new Tx3137Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("3138".equals(txCode)) {// P2P项目账户转账结算查询
                Tx3138Response txResponse = new Tx3138Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("3146".equals(txCode)) {// P2P还款查询
                Tx3146Response tx3146Response = new Tx3146Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3146Response.getResponsePlainText());
                if ("2000".equals(tx3146Response.getCode())) {
                    logger.info("[Message]=[" + tx3146Response.getMessage() + "]");
                    if (tx3146Response.getAccountType() == 11 || tx3146Response.getAccountType() == 12) {
                        logger.info("[BankID]=[" + tx3146Response.getBankID() + "]");
                        logger.info("[BankAccountName]=[" + tx3146Response.getBankAccountName() + "]");
                        logger.info("[BankAccountNumber]=[" + tx3146Response.getBankAccountNumber() + "]");
                        logger.info("[BankProvince]=[" + tx3146Response.getBankProvince() + "]");
                        logger.info("[BankCity]=[" + tx3146Response.getBankCity() + "]");
                    } else if (tx3146Response.getAccountType() == 20) {
                        logger.info("[PaymentAccountName]=[" + tx3146Response.getPaymentAccountName() + "]");
                        logger.info("[PaymentAccountNumber]=[" + tx3146Response.getPaymentAccountNumber() + "]");
                    }
                    if (tx3146Response.getStatus() == 30 || tx3146Response.getStatus() == 40) {
                        logger.info("[RepaymentTime]=[" + tx3146Response.getRepaymentTime() + "]");
                    }
                    // 处理业务
                }
            } else if ("3151".equals(txCode)) {// P2P字段投资
                Tx3151Response tx3151Response = new Tx3151Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3151Response.getResponsePlainText());
                if ("2000".equals(tx3151Response.getCode())) {
                    logger.info("[Message]=[" + tx3151Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3156".equals(txCode)) {// P2P字段投资
                Tx3156Response tx3156Response = new Tx3156Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3156Response.getResponsePlainText());
                if ("2000".equals(tx3156Response.getCode())) {
                    logger.info("[Message]=[" + tx3156Response.getMessage() + "]");
                }
            } else if ("3161".equals(txCode)) {// P2P项目批量结算（基本户）
                Tx3161Response tx3161Response = new Tx3161Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3161Response.getResponsePlainText());
                if ("2000".equals(tx3161Response.getCode())) {
                    logger.info("[Message]=[" + tx3161Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3162".equals(txCode)) {// P2P项目批量结算查询（基本户）
                Tx3162Response tx3162Response = new Tx3162Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3162Response.getResponsePlainText());
                if ("2000".equals(tx3162Response.getCode())) {
                    logger.info("[Message]=[" + tx3162Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3251".equals(txCode)) {
                Tx3251Response tx3251Response = new Tx3251Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3251Response.getResponsePlainText());
                if ("2000".equals(tx3251Response.getCode())) {
                    logger.info("[Message]=[" + tx3251Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3256".equals(txCode)) {
                Tx3256Response tx3256Response = new Tx3256Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3256Response.getResponsePlainText());
                if ("2000".equals(tx3256Response.getCode())) {
                    logger.info("[Message]=[" + tx3256Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3291".equals(txCode)) {// P2P到账
                Tx3291Response tx3291Response = new Tx3291Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3291Response.getResponsePlainText());
                if ("2000".equals(tx3291Response.getCode())) {
                    logger.info("[Message]=[" + tx3291Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3292".equals(txCode)) {// P2P到账查询
                Tx3292Response tx3292Response = new Tx3292Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3292Response.getResponsePlainText());
                if ("2000".equals(tx3292Response.getCode())) {
                    logger.info("[Message]=[" + tx3292Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3310".equals(txCode)) {// 优惠券批量下发
                Tx3310Response tx3310Response = new Tx3310Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3310Response.getResponsePlainText());
                if ("2000".equals(tx3310Response.getCode())) {
                    logger.info("[Message]=[" + tx3310Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3312".equals(txCode)) {// 优惠券批量查询
                Tx3312Response tx3312Response = new Tx3312Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3312Response.getResponsePlainText());
                if ("2000".equals(tx3312Response.getCode())) {
                    logger.info("[Message]=[" + tx3312Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3315".equals(txCode)) {// 优惠券过期回收
                Tx3315Response tx3315Response = new Tx3315Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3315Response.getResponsePlainText());
                if ("2000".equals(tx3315Response.getCode())) {
                    logger.info("[Message]=[" + tx3315Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3216".equals(txCode)) {// P2P项目支付查询（托管户）
                Tx3216Response tx3216Response = new Tx3216Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3216Response.getResponsePlainText());
                if ("2000".equals(tx3216Response.getCode())) {
                    logger.info("[Message]=[" + tx3216Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3231".equals(txCode)) {// P2P项目结算（托管户）
                Tx3231Response tx3231Response = new Tx3231Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3231Response.getResponsePlainText());
                if ("2000".equals(tx3231Response.getCode())) {
                    logger.info("[Message]=[" + tx3231Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3236".equals(txCode)) {// P2P项目结算查询（托管户）
                Tx3236Response tx3236Response = new Tx3236Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3236Response.getResponsePlainText());
                if ("2000".equals(tx3236Response.getCode())) {
                    logger.info("[Message]=[" + tx3236Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3237".equals(txCode)) {// P2P项目账户转账结算（专属户）
                Tx3237Response txResponse = new Tx3237Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("3238".equals(txCode)) {// P2P项目账户转账结算查询（专属户）
                Tx3238Response txResponse = new Tx3238Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("3241".equals(txCode)) {// P2P还款
                Tx3241Response tx3241Response = new Tx3241Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3241Response.getResponsePlainText());
                if ("2000".equals(tx3241Response.getCode())) {
                    logger.info("[Message]=[" + tx3241Response.getMessage() + "]");
                    if (tx3241Response.getStatus() == 30 || tx3241Response.getStatus() == 40) {
                        logger.info("[RepaymentTime]=[" + tx3241Response.getRepaymentTime() + "]");
                    }
                }
            } else if ("3246".equals(txCode)) {// P2P还款查询
                Tx3246Response tx3246Response = new Tx3246Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3246Response.getResponsePlainText());
                if ("2000".equals(tx3246Response.getCode())) {
                    logger.info("[Message]=[" + tx3246Response.getMessage() + "]");
                    if (tx3246Response.getAccountType() == 11 || tx3246Response.getAccountType() == 12) {
                        logger.info("[BankID]=[" + tx3246Response.getBankID() + "]");
                        logger.info("[BankAccountName]=[" + tx3246Response.getBankAccountName() + "]");
                        logger.info("[BankAccountNumber]=[" + tx3246Response.getBankAccountNumber() + "]");
                        logger.info("[BankProvince]=[" + tx3246Response.getBankProvince() + "]");
                        logger.info("[BankCity]=[" + tx3246Response.getBankCity() + "]");
                    } else if (tx3246Response.getAccountType() == 20) {
                        logger.info("[PaymentAccountName]=[" + tx3246Response.getPaymentAccountName() + "]");
                        logger.info("[PaymentAccountNumber]=[" + tx3246Response.getPaymentAccountNumber() + "]");
                    }
                    if (tx3246Response.getStatus() == 30 || tx3246Response.getStatus() == 40) {
                        logger.info("[RepaymentTime]=[" + tx3246Response.getRepaymentTime() + "]");
                    }
                }
            } else if ("3261".equals(txCode)) {// P2P项目批量结算（托管户）
                Tx3261Response tx3261Response = new Tx3261Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3261Response.getResponsePlainText());
                if ("2000".equals(tx3261Response.getCode())) {
                    logger.info("[Message]=[" + tx3261Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("3262".equals(txCode)) {// P2P项目批量结算查询（托管户）
                Tx3262Response tx3262Response = new Tx3262Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx3262Response.getResponsePlainText());
                if ("2000".equals(tx3262Response.getCode())) {
                    logger.info("[Message]=[" + tx3262Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4202".equals(txCode)) {// 统一账户注册结果查询
                Tx4202Response txResponse = new Tx4202Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("4206".equals(txCode)) {// 用户支付账户客户信息批量查询（统一户）
                Tx4206Response tx4206Response = new Tx4206Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4206Response.getResponsePlainText());
                if ("2000".equals(tx4206Response.getCode())) {
                    logger.info("[Message]=[" + tx4206Response.getMessage() + "]");
                }
            } else if ("4211".equals(txCode)) {// 支付账户余额查询解约
                Tx4211Response tx4211Response = new Tx4211Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4211Response.getResponsePlainText());
                if ("2000".equals(tx4211Response.getCode())) {
                    logger.info("[Message]=[" + tx4211Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4221".equals(txCode)) {// 支付账户扣款解约
                Tx4221Response tx4221Response = new Tx4221Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4221Response.getResponsePlainText());
                if ("2000".equals(tx4221Response.getCode())) {
                    logger.info("[Message]=[" + tx4221Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4212".equals(txCode)) {// 支付账户余额查询
                Tx4212Response tx4212Response = new Tx4212Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4212Response.getResponsePlainText());
                if ("2000".equals(tx4212Response.getCode())) {
                    logger.info("[Message]=[" + tx4212Response.getMessage() + "]");
                    // 处理业务
                }

            } else if ("4232".equals(txCode)) {// 用户支付账户注册查询
                Tx4232Response txResponse = new Tx4232Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("4237".equals(txCode)) {// 用户支付账户注册查询
                Tx4237Response tx4237Response = new Tx4237Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4237Response.getResponsePlainText());
                if ("2000".equals(tx4237Response.getCode())) {
                    logger.info("[Message]=[" + tx4237Response.getMessage() + "]");
                }
            } else if ("4236".equals(txCode)) {// 账户认证等级批量查询（专属）
                Tx4236Response tx4236Response = new Tx4236Response(respMsg[0], respMsg[1]);

                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4236Response.getResponsePlainText());
                if ("2000".equals(tx4236Response.getCode())) {
                    logger.info("[Message]=[" + tx4236Response.getMessage() + "]");
                }
            } else if ("4238".equals(txCode)) {// 用户支付账户余额批量查询（专属账户）
                Tx4238Response tx4238Response = new Tx4238Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4238Response.getResponsePlainText());
                if ("2000".equals(tx4238Response.getCode())) {
                    logger.info("[Message]=[" + tx4238Response.getMessage() + "]");
                }
            } else if ("4239".equals(txCode)) {// 账户信息查询
                Tx4239Response tx4239Response = new Tx4239Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4239Response.getResponsePlainText());
                if ("2000".equals(tx4239Response.getCode())) {
                    logger.info("[Message]=[" + tx4239Response.getMessage() + "]");
                }
            } else if ("4244".equals(txCode)) {
                Tx4244Response tx4244Response = new Tx4244Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4244Response.getResponsePlainText());

                if ("2000".equals(tx4244Response.getCode())) {
                    logger.info("[Message]=[" + tx4244Response.getMessage() + "]");
                    if (tx4244Response.getPaymentBankAccountList() != null) {
                        int size = tx4244Response.getPaymentBankAccountList().size();
                        for (int i = 0; i < size; i++) {
                            PaymentBankAccount item = tx4244Response.getPaymentBankAccountList().get(i);
                            logger.info("[BankID]=[" + item.getBankID() + "]");
                            logger.info("[BankAccountNumber]=[" + item.getBankAccountNumber() + "]");
                            logger.info("[BindingSystemNo]=[" + item.getBindingSystemNo() + "]");
                            logger.info("[Status]=[" + item.getStatus() + "]");
                        }
                    }
                    // 处理业务
                }
            } else if ("4252".equals(txCode)) {// 用户支付账户充值查询（托管户）
                Tx4252Response tx4252Response = new Tx4252Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4252Response.getResponsePlainText());
                if ("2000".equals(tx4252Response.getCode())) {
                    logger.info("[Message]=[" + tx4252Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4256".equals(txCode)) {// 用户支付账户提现查询（托管户）
                Tx4256Response tx4256Response = new Tx4256Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4256Response.getResponsePlainText());
                if ("2000".equals(tx4256Response.getCode())) {
                    logger.info("[Message]=[" + tx4256Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4262".equals(txCode)) {// 支付账户扣款签约查询
                Tx4232Response txResponse = new Tx4232Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("4264".equals(txCode)) {// 支付账户扣款解约(托管户)
                Tx4264Response tx4264Response = new Tx4264Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4264Response.getResponsePlainText());
                if ("2000".equals(tx4264Response.getCode())) {
                    logger.info("[Message]=[" + tx4264Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4273".equals(txCode)) {// 专属账户解约（移动端）
                Tx4273Response tx4273Response = new Tx4273Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4273Response.getResponsePlainText());
                if ("2000".equals(tx4273Response.getCode())) {
                    logger.info("[Message]=[" + tx4273Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4276".equals(txCode)) {// 专属账户解约（移动端）
                Tx4276Response tx4276Response = new Tx4276Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4276Response.getResponsePlainText());
                if ("2000".equals(tx4276Response.getCode())) {
                    logger.info("[Message]=[" + tx4276Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4280".equals(txCode)) {// P2P字段投资
                Tx4280Response tx4280Response = new Tx4280Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", tx4280Response.getResponsePlainText());
                if ("2000".equals(tx4280Response.getCode())) {
                    logger.info("[Message]=[" + tx4280Response.getMessage() + "]");
                    // 处理业务
                }
            } else if ("4321".equals(txCode)) {// 自动投资签约查询
                Tx4321Response txResponse = new Tx4321Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("4328".equals(txCode)) {// 自动投资解约
                Tx4328Response txResponse = new Tx4328Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("4333".equals(txCode)) {// 统一账户解约
                Tx4333Response txResponse = new Tx4333Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } else if ("4336".equals(txCode)) { // 统一账户签约查询
                Tx4336Response txResponse = new Tx4336Response(respMsg[0], respMsg[1]);
                request.setAttribute("txCode", txCode);
                request.setAttribute("txName", txName);
                request.setAttribute("plainText", txResponse.getResponsePlainText());
                if ("2000".equals(txResponse.getCode())) {
                    logger.info("[Message]=[" + txResponse.getMessage() + "]");
                }
            } 
            
            // 转向Response.jsp页面
            request.getRequestDispatcher("/Response.jsp").forward(request, response);            
        } catch (Exception e) {
        	e.printStackTrace();
        	processException(request, response, e.getMessage());
        }
    }

    public void setRequestAttribute(HttpServletRequest request, TxBaseResponse txResponse, String txCode, String txName) {
        request.setAttribute("txCode", txCode);
        request.setAttribute("txName", txName);
        request.setAttribute("plainText", txResponse.getResponsePlainText());
        if ("2000".equals(txResponse.getCode())) {
            logger.info("[Message]=[" + txResponse.getMessage() + "]");
            // 处理业务
        }
    }

    private void processException(HttpServletRequest request, HttpServletResponse response, String errorMessage) {
        try {
            request.setAttribute("errorMessage", errorMessage);
            request.getRequestDispatcher("/ErrorPage.jsp").forward(request, response);
        } catch (Exception e) {
        }
    }

}